import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    shopList:[],
  },
  mutations: {
    gteDateilData(state,item){
      state.shopList=item
    },
    changeSelect(state,iid) {
      state.shopList.forEach(v=>{
        if(v.iid===iid) {
          v.Select = !v.Select
        }
      })
    }
  },
  getters:{
    allPrice(state) {
      let price = 0
      state.shopList.forEach((v,i)=>{
        if(v.Select) {
          price += v.price * v.num
        }
     })
     return price
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [createPersistedState()]
})
